package com.analyse.stock.model;

import cn.hutool.core.date.DateUtil;
import com.analyse.stock.vo.PickStockVO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_fund_top_board_stock ")
public class FundTopBoardStockModel extends BaseModel<FundTopBoardStockModel> {
    /**
     * 发生日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date occDate;

    /**
     * 股票代码
     */
    private String stockCode;

    /**
     * 股票名称
     */
    private String stockName;

    /**
     * 板块编码
     */
    private String boardCode;

    /**
     * 板块名称
     */
    private String boardName;

    /**
     * 主力净流入金额
     */
    private BigDecimal mainSumAmt;

    /**
     * 换手率（%）
     */
    private BigDecimal exchangeRate;

    /**
     * 最新价格（元）
     */
    private BigDecimal price;

    /**
     * 涨跌幅度（%）
     */
    private BigDecimal upDownPercent;

    public static FundTopBoardStockModel transModel(PickStockVO stockVO){
        FundTopBoardStockModel stockModel = new FundTopBoardStockModel();
        stockModel.setBoardCode(stockVO.getBoardCode());
        stockModel.setBoardName(stockVO.getBoardName());
        stockModel.setStockCode(stockVO.getStockCode());
        stockModel.setStockName(stockVO.getStockName());
        stockModel.setOccDate(DateUtil.date());
        stockModel.setMainSumAmt(stockVO.getBuyAmt());
        stockModel.setExchangeRate(stockVO.getExchangeRate());
        stockModel.setPrice(stockVO.getPrice());
        stockModel.setUpDownPercent(stockVO.getUpDownPercent());
        stockModel.setUpdateTime(DateUtil.date());
        stockModel.setCreateTime(DateUtil.date());
        return stockModel;
    }
}
